package com.dbappsecurity.core;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.tbruyelle.rxpermissions2.RxPermissions;

abstract public class CoreBaseFragment extends Fragment {

  abstract protected  @LayoutRes int getLayout();


  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
      @Nullable Bundle savedInstanceState) {
    //View rootView = inflater.inflate(getLayout(),container,false);
    return inflater.inflate(getLayout(),container,false);
  }

  @Override
  public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (getActivity() instanceof CoreBaseActivity)
      ((CoreBaseActivity) getActivity()).registerFragment(this);
  }

  @Override
  public void onDestroyView() {
    super.onDestroyView();
    if (getActivity() instanceof CoreBaseActivity)
      ((CoreBaseActivity) getActivity()).unregisterFragment(this);
  }

  public boolean onKeyDown(int keyCode, KeyEvent event) {
    return false;
  }
}
